"""This is plugin module.

Each plugin must be a submodule to this module and must provide
`getClass` method. (One that returns main plugin class).

"""

import os

from app.util import path

def getPluginList():
    """Return list of acceptable plugin modules."""
    _curDir = path.getModulePath("app.plugins")
    return sorted(_name
        for _name in os.listdir(_curDir)
        if os.path.isdir(os.path.join(_curDir, _name)) and \
        not _name.startswith(".")
    )

def getPluginClass(name):
    """Return class for plugin with given name."""
    _module = __import__("app.plugins", {}, {}, [name])
    _module = getattr(_module, name)
    return _module.getClass()

# vim: set sts=4 sw=4 et :
